#include<stdio.h>
#include"../include/file_descriptor.h"
#include"../include/block.h"
#include"../include/free_list.h"
#include"../include/main_header.h"
#include"../include/hashtab.h"
#include"../include/bst.h"
#include"../include/narray.h"
#include<string.h>
//char *command(char *choice_str);
//void getpara(char *choice_str);
//char para1[20],para2[20],para3[20];

int main()
{




//initializeHashTable(hashTable);
//createroot();
//initailizeFDList();
char fname[11], fpath[100],vfspath[100],filename[20],diskpath[100],src[100],dest[100];
int SUCCESS = 0,choice,flag;
while(1)
{
printf("\n============VFS10============\n");
printf("\nEnter choice\n1:create vfs\n2:mount vfs\n3:create files\n4:list dir\n5:test function\n6:unmount vfs\n7:hashTable search\n8:BST search\n9:Add file\n10:make dir\n11:Exportfile\n12:Copy file\n");
scanf("%d",&choice);

switch (choice)
	{
	case 1:create_vfs();
		break;
	case 2:mount_vfs();
		traverseFDList();
	
		display(root);
		break;
	case 3:	
		//make_dir("/","folder1");
		//create_file("/folder1/","test4","file3");
	
		break;
	case 4:	
		printf("%s\n", "Enter derectory path ");
		scanf("%s", vfspath);
		printf("%s\n", "Enter flag\n 0 for recursive\n 1 for non recursivve ");
		scanf("%d",&flag);
		printf("%s\n", "Enter disk path");
		scanf("%s",diskpath);
		
		displaystub(vfspath,flag,diskpath);
		//listfile("/folder1/folder2/folder13/","me");
		
		//listdir("/folder1/folder2/folder13/");
		//display(root);		
		break;
	case 5:	test();//file_content();
		break;
	case 6:	unmount_vfs();//file_content();
		//test_disk();
		break;	
	case 7:

		printf("Enter file name: ");
		scanf("%s", fname);
		searchFileInHashTable(fname, hashTable);
		break;

	case 8:
		printf("Enter file path: ");
		scanf("%s", fname);
		SUCCESS = searchBST(bst_root, fname, strlen(fname));
		printf("%s%d\n", "Success: ", SUCCESS);
				
		break;
	case 9:
		printf("%s\n", "Enter VFS path ");
		scanf("%s", vfspath);
		printf("%s\n", "Enter file name ");
		scanf("%s",filename);
		printf("%s\n", "Enter disk path");
		scanf("%s",diskpath);
		addfile(vfspath, filename,diskpath);	
		traverseFDList();	
		break;
	case 10:
		printf("%s\n", "Enter path ");
		scanf("%s", fpath);
		printf("%s\n", "Enter name ");
		scanf("%s", fname);
		makedir(fpath, fname);	
		traverseFDList();	
		break;
	case 11:
		printf("%s\n", "Enter VFS path ");
		scanf("%s", vfspath);
		
		printf("%s\n", "Enter disk path");
		scanf("%s",diskpath);
		
		exportfile(vfspath,diskpath);
		break;
	case 12:
		printf("%s\n", "Enter VFS source path ");
		scanf("%s", src);
		
		printf("%s\n", "Enter VFS destination path");
		scanf("%s",dest);
		copyfile(src,dest);

		default:
			printf("wrong choice");
			break;
	}
}
return 0;
}
/*
void command(char *choice_str)
{
char command[20];
int i=0
	while(choice_str!=' ')
	{
		command[i]=*choice_str;
		choice_str++;
		i++;
	}
command[i]='\0';
return command;
}
void getpara(char *choice_str)
{
int i;
	while(choice_str!=' ')
	{
		choice_str++;
	}
	i=0;
	while(choice_str!=' ')
	{
		para1[i]=*choice_str;
		choice_str++;
		i++;
		if(choice_str=='\0')
		{
			return;		
		}
	}
para1[i]='\0';

i=0;
	while(choice_str!=' ')
	{
		para2[i]=*choice_str;
		choice_str++;
		i++;
		if(choice_str=='\0')
		{
			return;		
		}
	}
para2[i]='\0';

i=0;
	while(choice_str!=' ')
	{
		para3[i]=*choice_str;
		choice_str++;
		i++;
		if(choice_str=='\0')
		{
			return;		
		}
	}
para3[i]='\0';

}
*/
